<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>rem布局</title>
</head>

<body>
    <!---rem是一个相对单位，它的单位就是html根元素的font-size的大小-->

    <div class="main">
        <div class="catalog">
            <ul>
                <li>
                    <div class="content">
                        <img src="https://image1.suning.cn/uimg/cms/img/165710989476671143.png?from=mobile" alt="">
                        <div class="content_img"><span>苏宁家电</span></div>
                    </div>

                </li>
                <li>
                    <div class="content">
                        <img src="https://image1.suning.cn/uimg/cms/img/165710989476671143.png?from=mobile" alt="">
                        <div><span style="font-size: 14px"></span></div>
                    </div>
                </li>
                <li>
                    <div class="content">
                        <img src="https://image1.suning.cn/uimg/cms/img/165710989476671143.png?from=mobile" alt="">
                        <div><span style="font-size: 14px"></span></div>
                    </div>
                </li>
                <li>
                    <div class="content">
                        <img src="https://image1.suning.cn/uimg/cms/img/165710989476671143.png?from=mobile" alt="">
                        <div><span style="font-size: 14px"></span></div>
                    </div>
                </li>
                <li>
                    <div class="content">
                        <img src="https://image1.suning.cn/uimg/cms/img/165710989476671143.png?from=mobile" alt="">
                        <div><span style="font-size: 14px"></span></div>
                    </div>
                </li>
            </ul>
        </div>
    </div>

</body>
<script>
    let htmlDom = document.getElementsByTagName('html')[0];
    htmlDom.style.fontSize = document.documentElement.clientWidth / 20 + 'px';
    //window 窗口 窗户 是一个对象 onresize
    window.onresize = function () {
        //document对象是文档的根节点，每张网页都有自己的document对象只要浏览器开始载入 HTML 文档，该对象就存在了，可以直接使用
        // console.log(document);
        console.log(document.documentElement.clientWidth)
        console.log(document.documentElement.clientWidth / 20);
        // // 获取html的dom
        // document.getElementsByTagName
        let htmlDom = document.getElementsByTagName('html')[0];
        htmlDom.style.fontSize = document.documentElement.clientWidth / 20 + 'px';
        // console.log(htmlDom.style.fontSize);
        // console.log("------------我被触发了-------------")
    }


</script>

<style>
    /* @media screen and (min-width:375px) {
        html {
            font-size: 18.75px;
        }
    }
    @media screen and (min-width:750px) {
        html {
            font-size: 37px;
        }
    } */


    body {
        margin: 0;
    }

    .main {
        width: 20rem;
        height: 7.57333rem;
        background-color: aqua;
    }

    .catalog {
        width: 20rem;
        height: 7.57333rem;
        background-color: aqua;
    }

    .catalog ul {
        list-style: none;
        margin: 0;
        padding: 0;
        height: 100%;
    }

    .catalog ul li {
        width: 4rem;
        height: 50%;
        background-color: beige;
        float: left;
    }

    .content {
        width: 3rem;
        height: 2.9rem;
        margin: 0 auto;
        text-align: center;
        position: relative;

    }

    img {
        position: absolute;
        left: 0.38rem;
        width: 2.24rem;
        height: 2.24rem;
    }

    .content_img{
        position: absolute;
        top: 2.3rem;
    
    }

    .content_img {
        font-size: 0.746rem;
    }
</style>

</html>